home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48hor1
/
facnum.doc
< prev
next >
Wrap
Text File
|
1995-03-31
|
1KB
|
32 lines
Article: 4251 of comp.sys.handhelds
Author: Mark Adler (madler@piglet.caltech.edu)
Subject: Breaking out of loops on the HP-48SX
Date: 11 Nov 90 00:27:58 GMT
Organization: California Institute of Technology, Pasadena
I just discovered a technique that I thought I'd share. The HP-48SX
appears to lack a way to break out of loops. But appearances can be
deceiving. There is a kludgey way to do it. You can put the loop
in an IFERR statement, and then divide by zero or some such thing to
cause an error. This appears to cleanly exit the loop (or loops).
As an example of this tehcnique, here is a program (FACNUM) which
will take a whole number and return its prime factorization as a
list of primes, repeated if necessary. I wanted to avoid having the
inner loop do two tests, so it could be a simple FOR loop, and so
the loop exit is done inside IF statements with a divide by zero.
A note to HP: please include a throw/catch operation for exiting
loops on the next calculator (48SY? 49?). The code to handle
cleaning up leftover constructs appears to already be there for
IFERR. Thanks.
Mark Adler
madler@piglet.caltech.edu
[Note: Mark's FACNUM program is about twice as fast as my PF on the HORN1
disk. Good work, Mark! Now who will write it in ML?? -jkh-]
[Later note: Klaus Kalb did! See TRIAL on this disk. -jkh-]
[Even later note: Jurjen Bos perfected it; see FACTOR. -jkh-]